﻿const _=require('lodash');
const managerService=require('../../../app/service/o2o_admin/manager.server.service.js');
const winston = require('../../../app/utils/winstonLogger.js');

module.exports={
    findByUnameAndPassword:findByUnameAndPassword
}

function findByUnameAndPassword(request,response,next){
    let m=request.body.manager;
    if(_.isEmpty(m)){
        winston.error("manager login is empty");
        return next(new Error("manager login is empty"));
    }
    else{
        managerService.findByUnameAndPassword(m.uname,m.password,(error,result)=>{
            if(error){
                winston.error(error.message);
                return next(new Error(error));
            }else{
                winston.info("findByUnameAndPassword success");
                response.json(result);
            }
        });
    }
}



